﻿<BadHabit_WPFTools:ShapedWindow
    x:Class="BadHabit.Factory.Windows.EditRoles"
    x:Name="window"
    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Factory_Core="clr-namespace:BadHabit.Factory;assembly=FactoryCore"    
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"        
    xmlns:BadHabit_WPFTools_Converters="clr-namespace:BadHabit.WPFTools.Converters;assembly=BadHabit.WPFTools"
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    
    xmlns:props="clr-namespace:BadHabit.Factory.Properties"

    Loaded="EditRoles_Loaded"
    
    Style="{StaticResource DialogEditWindow}"            
    Title="{x:Static props:Resources.Project_Roles}"
    
    WindowStartupLocation="CenterOwner"
    Width="600"
    SizeToContent="Height"
    MaxHeight="600"
    >
    
    <BadHabit_WPFTools:ShapedWindow.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Undo" Executed="Undo_Executed"/>
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save_Executed"/>
    </BadHabit_WPFTools:ShapedWindow.CommandBindings>
    
    <BadHabit_WPFTools:ShapedWindow.Resources>
        
        <CollectionViewSource x:Key="BacklogItemUnitList" Source="{Binding BacklogItemUnit}">
            <CollectionViewSource.SortDescriptions>
               <scm:SortDescription PropertyName="Type" Direction="Ascending" />
                <scm:SortDescription PropertyName="UnitDescription" Direction="Ascending" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        
 
        
        
        <DataTemplate x:Key="RoleTypeTemplate">
            <Grid HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" Style="{StaticResource RoleTypeImage}" Margin="0,0,2,0" Width="15" Height="16" Stretch="Uniform"/>
                <TextBlock Grid.Column="1" Text="{Binding}" HorizontalAlignment="Stretch"/>
            </Grid>
        </DataTemplate>
        
    </BadHabit_WPFTools:ShapedWindow.Resources>

                    

    <Border
        Grid.Row="0"                
        Margin="4"
        Style="{StaticResource RoundBorder}">

        <BadHabit_WPFTools:DataGrid
            x:Name="backlogItemUnitDataGrid"            
            BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER"
            
            UseNavigationExtensions="True"
            ItemsSource="{Binding Source={StaticResource BacklogItemUnitList}}"
            AutoGenerateColumns="False"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            
        
        
     
        CanUserDeleteRows="True"
        CanUserAddRows="True"
        CanUserSortColumns="False"
        CanUserReorderColumns="False"
            
        InitializingNewItem="backlogItemUnitDataGrid_InitializingNewItem"
    
        ScrollViewer.HorizontalScrollBarVisibility="Disabled">

            <Microsoft_Toolkit:DataGrid.Columns>

                <Microsoft_Toolkit:DataGridTemplateColumn                                         
                    x:Name="typeColumn"
                    Header="{x:Static props:Resources.Type}"
                    CanUserResize="False"                                                                      
                    Width="Auto">
                    <Microsoft_Toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <BadHabit_WPFTools:ComboBox   
                                Width="150"
                                DropDownBackground="White"                                                  
                                SelectedItemTemplate="{StaticResource RoleTypeTemplate}"
                                ItemTemplate="{StaticResource RoleTypeTemplate}"
                                SelectedValue="{Binding Type, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:TeamRoles}}"                                                                            
                                ItemsSource="{Binding Source={StaticResource TeamRolesList}}"/>
                        </DataTemplate>
                    </Microsoft_Toolkit:DataGridTemplateColumn.CellTemplate>
                </Microsoft_Toolkit:DataGridTemplateColumn>

                <Microsoft_Toolkit:DataGridTextColumn
                    x:Name="roleColumn"
                    Header="{x:Static props:Resources.Role}"                        
                    Width="*"
                    CanUserResize="False"                                                                         
                    Binding="{Binding UnitDescription}">
                    <Microsoft_Toolkit:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox" BasedOn="{StaticResource TransparentEditingElementStyle}">
                            <Setter Property="MaxLength" Value="50"/>
                        </Style>
                    </Microsoft_Toolkit:DataGridTextColumn.EditingElementStyle>
                </Microsoft_Toolkit:DataGridTextColumn>

                <Microsoft_Toolkit:DataGridTextColumn                                                
                    x:Name="shortNameColumn"
                    CanUserResize="False"
                    Header="{x:Static props:Resources.Short_Name}"                                                
                    Binding="{Binding UnitName}">
                    <Microsoft_Toolkit:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox" BasedOn="{StaticResource TransparentEditingElementStyle}">
                            <Setter Property="MaxLength" Value="50"/>
                        </Style>
                    </Microsoft_Toolkit:DataGridTextColumn.EditingElementStyle>
                </Microsoft_Toolkit:DataGridTextColumn>


                <Microsoft_Toolkit:DataGridTextColumn                                    
                    x:Name="hourCostColumn"
                    Header="{x:Static props:Resources.Hour_Cost}"                        
                    CanUserResize="False"                                                  
                    CellStyle="{StaticResource RightAlignCellStyle}"       
                    HeaderStyle="{StaticResource RightAlignColumnStyle}"
                    Binding="{Binding UnitCostValue, StringFormat='{}{0:C}'}"/>
                
                <Microsoft_Toolkit:DataGridTextColumn                                    
                    x:Name="hourPriceColumn"
                    Header="{x:Static props:Resources.Hour_Price}"                        
                    CanUserResize="False"                                                  
                    CellStyle="{StaticResource RightAlignCellStyle}"       
                    HeaderStyle="{StaticResource RightAlignColumnStyle}"
                    Binding="{Binding UnitSaleValue, StringFormat='{}{0:C}'}"/>


            </Microsoft_Toolkit:DataGrid.Columns>

        </BadHabit_WPFTools:DataGrid>

    </Border>


</BadHabit_WPFTools:ShapedWindow>
